import { createRouter, createWebHashHistory } from "vue-router";
import Home from "@/views/Home.vue";

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: "/",
      redirect: "/home",
    },
    {
      path: "/home",
      name: "home",
      component: Home,
      meta: {
        // 设置该路由在TabBar中的顺序
        index: 1,
      },
    },
    {
      path: "/login",
      name: "login",
      component: () => import("@/views/Login.vue"),
      meta: {
        index: 1,
      },
    },

    {
      path: "/user",
      name: "user",
      component: () => import("@/views/User.vue"),
      meta: {
        index: 1,
      },
    },
    {
      path: "/category",
      name: "category",
      component: () => import("@/views/Category.vue"),
      meta: {
        index: 1,
      },
    },
    {
      path: "/cart",
      name: "cart",
      component: () => import("@/views/Cart.vue"),
      meta: {
        index: 1,
      },
    },
    {
      path: "/detail",
      name: "detail",
      component: () => import("@/views/Detail.vue"),
      meta: {
        index: 1,
      },
      props: true,
    },
    {
      path: "/product-list",
      name: "product-list",
      component: () => import("@/views/ProductList.vue"),
      meta: {
        index: 2,
      },
    },
    {
      path: "/product",
      name: "product",
      component: () => import("@/views/ProductDetail.vue"),
      meta: {
        index: 3,
      },
    },
  ],
});

export default router;
